window.onload=function()
{
    rightNav();
    backTop();
    setSearchValue();
};

function setSearchValue() {
    url = window.location.href;
    if(url.indexOf('?')>=1){
        var params = urlToArr(url.split('?')[1])
        if(params.price!=''&&params.price!=undefined){
            if((params.price).indexOf('-')>=1){
                prices = (params.price).split('-');
                var minPrice = $('form.goods-price-search input[name="min-price"]').val(prices[0]);
                $('form.goods-price-search input[name="max-price"]').val(prices[1]);
            }else{
                $('form.goods-price-search input[name="min-price"]').val(params.price);
            }
        }
    }
}

function goodsSort(sortType) {
    url =  handleUrl({"psort":sortType});
    window.location = url;
}

function goodsPriceSearch() {
    var minPrice = $('form.goods-price-search input[name="min-price"]').val();
    var maxPrice = $('form.goods-price-search input[name="max-price"]').val();

    if(!minPrice&&!maxPrice){
        return false;
    }

    if(minPrice == ''){
        minPrice = 0;
    }else{
        minPrice = Math.abs(minPrice);
    }
    if(maxPrice == ''){
        var exPrice = minPrice
    }else{
        maxPrice = Math.abs(maxPrice);
        var exPrice = minPrice+"-"+maxPrice;
    }

    url =  handleUrl({"price":exPrice});
    window.location = url;
}
